package com.igoal.service.dwr;

import java.util.List;

import org.appfuse.service.UserExistsException;
import org.springframework.transaction.annotation.Transactional;

import com.igoal.dto.CompanyDTO;
import com.igoal.dto.HobbyDTO;
import com.igoal.dto.SchoolDTO;
import com.igoal.dto.UserDTO;
import com.igoal.dto.UserInfoDTO;
import com.igoal.dto.UserStatusDTO;
import com.igoal.service.ContactVendorEnum;
import com.igoal.service.SaveResult;

public interface UserManagerDWR {
	/**
	 * Check the user has logined or not
	 * @param username
	 * @return true if logined
	 */
	boolean isLogined();
	
	/**
	 * Login user
	 * @param username
	 * @param password
	 * @return {@link UserDTO} if login successfully, unless return null
	 */
	UserDTO login(String username, String password);
	
	/**
	 * Validate username and password
	 * @param username
	 * @param password
	 * @return true if valid information
	 */
	// boolean validateLogin(String username, String password);
	
	/**
	 * Search user by any match information with <i>text</i>
	 * <br/>ignore session user in list
	 * @param text
	 * @return list of {@link UserDTO}
	 */
	List<UserDTO> searchUser(String text);
	
	/**
	 * Register new user
	 * @param newUser
	 * @return 1 if registered successfully
	 * @throws UserExistsException
	 */
	@Transactional(readOnly=false)
	Long register(UserDTO newUser);
	
	/**
	 * Add friend to current session user
	 * @param friendId - identifier of an exist user
	 */
	@Transactional(readOnly=false)
	void addFriend(Long friendId);
	
	/**
	 * Add friends to userRequest
	 * @param friendIds - list of exist user
	 */
	@Transactional(readOnly=false)
	void addFriends(Long[] friendIds);
	
	/**
	 * Get status of user session
	 * <br/>Using by <b>Ajax</b> only
	 * @return
	 */
	UserStatusDTO getUserStatus();
	
	/**
	 * Save new status of user session
	 * <br/>Using by <b>Ajax</b> only
	 * @param status content of status
	 * @return {@link SaveResult}
	 */
	int saveUserStatus(String status);
	
	/**
	 * Retrieves a list of users except for current user session
	 * @return list of {@link UserDTO}
	 */
	List<UserDTO> getUsersExceptForMe();
	
	/**
     * Validate username is unique
     * @param username
     * @return 0 if valid
     */
	long validateUsername(String username);
	
	/**
	 * Validate email is unique
	 * @param email
	 * @return 0 if valid
	 */
	long validateEmail(String email);
	
	/**
	 * Find contact email inside provided user account
	 * @param vendor {@link ContactVendorEnum}
	 * @param username email vendor username
	 * @param password email vendor password
	 * @return list of contact from user's email contacts
	 */
	List<UserDTO> findContacts(ContactVendorEnum vendor, String username, String password);
	
	int updateStatus(String status);
	
	int likeThisEntry(long entryId);
	
	int likeThisDoneEntry(long entryId);
	
	int likeThisComment(long commentId);
	
	int unlikeThisEntry(long entryId);
	
	int unlikeThisDoneEntry(long entryId);
	
	int unlikeThisComment(long commentId);
	
	int saveAboutMe(String aboutMe);
	
	/**
	 * Check if this is the password of the current user
	 * 
	 * @param password
	 * @return
	 */
	boolean checkUserPassword(String password);
	
	int acceptFriend(String from);
	
	int refuseFriend(String from);
	
	int addCategories(Long[] categoryIds);
	
	int removeCategories(Long[] categoryIds);
	
	int thumbStatus(Long statusId, boolean up);
	
	int countThumbUp(Long statusId);
	
	int countThumbDown(Long statusId);
	
	int markReadNotification(Long[] notificationIds);
	
	int cheerThisDoneEntry(Long entryId);

	int cheerThisEntry(Long entryId);
	
	int getNewNotification();
	
	// long addThought(String wallOwner, String thought, String privacy);
	
	int updateUserBasicInformation(UserInfoDTO dto);
	
	int updateUserContactInformation(UserInfoDTO dto);
	
	int updateUserResidentInformation(UserInfoDTO dto);
	
	int updateUserSchool(SchoolDTO dto);
	
	int updateUserSchools(SchoolDTO[] schools);
	
	int updateUserCompany(CompanyDTO dto);
	
	int updateUserCompanies(CompanyDTO[] dto);
	
	int updateUserHobbies(HobbyDTO[] hobbies);
	
	int updateUserPassword(String oldPass, String newPass);
}
